package com.echat.messagesendertest.controller;

import com.echat.messagesender.sender.bean.EchatSendEmailInfo;
import com.echat.messagesender.sender.bean.EchatSendSmsInfo;
import com.echat.messagesender.sender.service.EchatEmailSendService;
import com.echat.messagesender.sender.service.EchatSmsSendService;
import com.weibo.api.motan.config.springsupport.annotation.MotanReferer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by chenmohan on 2018/08/13
 *
 * @description
 */
@RestController
public class HelloController {

    @MotanReferer(basicReferer = "motantestClientBasicConfig")
    EchatEmailSendService emailSendService;

    @MotanReferer(basicReferer = "motantestClientBasicConfig")
    EchatSmsSendService smsSendService;

    @GetMapping("/email")
    public String printEmail(){
        EchatSendEmailInfo echatSendEmailInfo = new EchatSendEmailInfo();
        echatSendEmailInfo.setUserId(1847914544631808L);
        echatSendEmailInfo.setTitle("[9/14]随便写的一封邮件");
        echatSendEmailInfo.setContent("啊啊啊啊啊啊啊啊");
        echatSendEmailInfo.setReceivers(new String[]{"719078369@163.com"});
        return emailSendService.sendEmail(echatSendEmailInfo)?"email ok":"email bu ok";
    }

    @GetMapping("/sms")
    public String printSms(){
        EchatSendSmsInfo echatSendSmsInfo = new EchatSendSmsInfo();
        echatSendSmsInfo.setUserId(1847914544631808L);
        echatSendSmsInfo.setSmsContent("[9/14]写的一条短信");
        echatSendSmsInfo.setPhonoNos(new String[]{"13419409415"});
        return smsSendService.sendSMS(echatSendSmsInfo)?"sms ok":"sms bu ok";
    }

}
